package com.bestcem.xm.ticket.controller.vo.ticket.template;

import com.bestcem.xm.ticket.constant.ColumnConstant;
import com.bestcem.xm.ticket.enums.TemplateTypeEnum;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;

import java.io.Serializable;
import java.util.List;

/**
 * 获取字段详情vo
 *
 * @author xuan.yang <xuan.yang@idiaoyan.com>
 * @version v1.0
 * @date 2021/9/9 11:08
 */
@ToString(callSuper = true)
@Getter
@Setter
public class GetTemplateInfoVO {
    private static final long serialVersionUID = -7253778583948098510L;

    private String id;

    private String name;
    /**
     * type
     * 模板类型1-详情，2-处理模板 {@link TemplateTypeEnum}
     */

    private Integer type;

    @JsonProperty(value = ColumnConstant.TicketTemplateV2.FIELD_LIST)
    private List<FieldInfo> fieldInfos;

    @NoArgsConstructor
    @AllArgsConstructor
    @Data
    public static class FieldInfo implements Serializable {
        private static final long serialVersionUID = 2808726620840986656L;

        /**
         * name
         */
        private String name;
        /**
         * type
         * text--1单行文本； multiLine--2 多行文本；
         * select---3单选； cascadeSelect--4 级联选择
         */
        private Integer type;
        /**
         * require
         * 默认false
         */
        private Boolean required = Boolean.FALSE;

        /**
         * filed
         * 字段key
         */
        private String field;
        /**
         * value
         * 单行或者多行的值
         */
        private String value;

        /**
         * singleSelectValue
         */
        @JsonProperty(value = ColumnConstant.TicketTemplateV2.FieldInfo.SINGLE_SELECT)
        private SingleSelect singleSelect;

        /**
         * CascadeValue
         */
        @JsonProperty(value = ColumnConstant.TicketTemplateV2.FieldInfo.CASCADE_LIST)
        private List<Cascade> cascadeList;

    }

    @NoArgsConstructor
    @AllArgsConstructor
    @Data
    public static class SingleSelect implements Serializable {
        private static final long serialVersionUID = 2808726620840986656L;

        /**
         * options
         * 当source为1的时候存在数值
         */
        @JsonProperty(value = ColumnConstant.TicketTemplateV2.SingleSelectValue.OPTION_LIST)
        private List<Option> optionList;

        /**
         * content
         */

        private String content;
        /**
         * source
         * 1-自定义数据，2-系统问卷数据 3-系统联系人数据
         */

        private Integer source;

        @NoArgsConstructor
        @AllArgsConstructor
        @Data
        public static class Option implements Serializable {
            private static final long serialVersionUID = 2808726620840986656L;
            /**
             * 层级列表
             */
            private String field;
            /**
             * 级联等级
             */
            private Integer value;

        }

    }

    @NoArgsConstructor
    @AllArgsConstructor
    @Data
    public static class Cascade implements Serializable {
        private static final long serialVersionUID = 2808726620840986656L;
        /**
         * 层级列表
         */
        @JsonProperty(value = ColumnConstant.TicketTemplateV2.Cascade.OPTION_LIST)
        private List<Option> optionList;
        /**
         * 级联等级
         */
        private Integer level;

    }

    @NoArgsConstructor
    @AllArgsConstructor
    @Data
    public static class Option implements Serializable {
        private static final long serialVersionUID = 2808726620840986656L;

        /**
         * id
         */
        private String id;
        /**
         * pid
         * 父id，存在多级关联
         * 父id的pid为0
         */
        private String pid;
        /**
         * value
         */
        private String value;

    }
}
